using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

using Peradigm.Framework.Domain.Security;
using Peradigm.Framework.Persistence;
using Peradigm.Framework.Domain.Parties;

namespace Liberty.Domain.CaseManagement
{
    [Serializable]
    public class Visit : PersistentModel 
    {
        #region Constants
        #endregion

        #region Event Handlers
        #endregion

        #region Methods
        /// <summary>
        /// Creates a stubbed visit populated with frequently used primitives.
        /// Other aggregated objects are not populated by this factory method.
        /// </summary>
        /// <returns></returns>
        public static Visit TestInstance()
        {
            Visit stub = new Visit( PersistentModel.NEW_OID, PersistentModel.NEW_VERSION, new Facility( "BMC", "BMC Hospital" ), true );        
            stub.DischargeDate = new DateTime( 2006, 7, 4 );
            stub.FamilyArrival = new DateTime( 2006, 7, 4 );
            stub.FamilyDepartureOn = new DateTime( 2006, 7, 4 );           
            stub.HasInvitationalTravelOrders = true;
            stub.MethodOfTravel = "Tank";
            stub.OriginOfTravel = "Some hospital";

            return stub;
        }
        #endregion

        #region Properties
        public DateTime? ArrivalDate
        {
            get
            {
                if ( i_ArrivalDate.HasValue )
                {
                    return i_ArrivalDate.Value;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if ( value.HasValue )
                {
                    i_ArrivalDate = value;
                }
                else
                {
                    i_ArrivalDate = null;
                }
            }
        }

        public DateTime? DischargeDate
        {
            get
            {
                if ( i_DischargeDate.HasValue )
                {
                    return i_DischargeDate.Value;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if ( value.HasValue )
                {
                    i_DischargeDate = value;
                }
                else
                {
                    i_DischargeDate = null;
                }
            }
        }

        public DateTime? FamilyArrival
        {
            get
            {
                if (i_FamilyArrival.HasValue)
                {
                    return i_FamilyArrival.Value;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if ( value.HasValue )
                {
                    i_FamilyArrival = value;
                }
                else
                {
                    i_FamilyArrival = null;
                }
            }
        }

        public DateTime? FamilyDepartureOn
        {
            get
            {
                if ( i_FamilyDepartureOn.HasValue )
                {
                    return i_FamilyDepartureOn.Value;
                }
                else
                {
                    return null;
                }
            }
            set
            {
                if ( value.HasValue )
                {
                    i_FamilyDepartureOn = value;
                }
                else
                {
                    i_FamilyDepartureOn = null;
                }
            }
        }

        public bool FamilyIsPresent
        {
            get
            {
                return i_FamilyIsPresent;
            }
            set
            {
                i_FamilyIsPresent = value;
            }
        }

        public bool HasInvitationalTravelOrders
        {
            get
            {
                return i_HasInvitationalTravelOrders;
            }
            set
            {
                i_HasInvitationalTravelOrders = value;
            }
        }

        public string MethodOfTravel
        {
            get
            {
                return i_MethodOfTravel;
            }
            set
            {
                i_MethodOfTravel = value;
            }
        }

        public string OriginOfTravel
        {
            get
            {
                return i_OriginOfTravel;
            }
            set
            {
                i_OriginOfTravel = value;
            }
        }

        public Facility Facility
        {
            get
            {
                return i_Facility;
            }
            set
            {
                i_Facility = value;
            }
        }
        #endregion

        #region Private Methods
        #endregion

        #region Private Properties
        #endregion

        #region Construction and Finalization
        [Obsolete( "Upgrade to the complete constructor." )]
        public Visit()
        {
            
        }

        public Visit( long oid, byte[] version,  Facility facility, bool familyIsPresent )
        {
            this.Oid = oid;
            this.Version = version;
            this.Facility = facility;
            this.FamilyIsPresent = familyIsPresent;
        }
        #endregion

        #region Data Elements
        private DateTime? i_ArrivalDate;
        private DateTime? i_DischargeDate;
        private DateTime? i_FamilyArrival;
        private DateTime? i_FamilyDepartureOn;
        private bool i_FamilyIsPresent;
        private bool i_HasInvitationalTravelOrders;
        private string i_MethodOfTravel;
        private string i_OriginOfTravel;
        private Facility i_Facility;
        #endregion

    }
}
